﻿using System;
using Microsoft.SqlServer.Management.Smo;

namespace Bewise.SmartIndexManager.Core.Classes.Options
{
    public class RequiredMinimumIndexOption : IndexOption
    {
        public RequiredMinimumIndexOption()
        {
            MinimumIndexSize = 10;
        }

        public int MinimumIndexSize { get; set; }

        public override bool CheckValidation()
        {
            bool isValid = false;
            try
            {
                isValid = IndexSource.SpaceUsed > MinimumIndexSize;
            }
            catch (Exception)
            {
                isValid = false;
            }
            return isValid;
        }

        public override string OptionName
        {
            get { return "RequiredMinimumIndexOption"; }
        }
    }
}